package Year21_Month10.day1030;
import java.util.Arrays;
import  java.util.Stack;

public class MinStack {
    Stack<Integer> a;
    Stack<Integer> b;

    public MinStack() {
        a = new Stack();
        b = new Stack();
    }

    public void push(int val) {
        if(b.empty() || a.peek() > val){
            b.push(val);
        }
        a.push(val);
    }

    public void pop() {
        if(b.peek() >= a.peek()){
            b.pop();
        }
        a.pop();
    }

    public int top() {
        if(a.empty()){
            return -1;
        }
        return a.peek();
    }

    public int getMin() {
        if(b.empty()){
            return -1;
        }
        return b.peek();
    }
}

